﻿Public Class fAddMob

    Dim colIDS As Collection

    Public Sub Init()

        '//////////////LOAD MOB NAMES

        colIDS = New Collection

        Dim ssql As String = "SELECT STR_NAME, ID_MON FROM TBL_MON;"
        Dim arr As ArrayList = DatabaseManager.DB_Game.ExecuteQuery(ssql)

        cmbMobName.BeginUpdate()
        cmbMobName.Items.Clear()

        If arr.Count > 0 Then

            For i As Integer = 0 To arr.Count - 1
                colIDS.Add(arr(i)("ID_MON"), arr(i)("STR_NAME"))
                cmbMobName.Items.Add(arr(i)("STR_NAME"))
            Next

        End If

        cmbMobName.EndUpdate()

        '///////////////////////////////

    End Sub

    Private mMapName As String
    Private pX As Integer
    Private pY As Integer

    Public Sub ShowAddMob(x As Integer, y As Integer, w As Integer, h As Integer, mapName As String)

        mMapName = mapName

        pX = x
        pY = y

        '///////////////ranges

        Dim rX As Integer

        If x > w / 2 Then
            rX = w - x
        Else
            rX = x
        End If


        Dim rY As Integer

        If y > h / 2 Then
            rY = h - y
        Else
            rY = y

        End If

        numXRange.Maximum = rX
        numYRange.Maximum = rY

        '////////////////////

        Me.Show()

    End Sub

    Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click

        MyBase.Hide()

    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click

        Editor.Mobs.AddSpawn(mMapName, colIDS(cmbMobName.SelectedItem), pX, pY, numXRange.Value, numYRange.Value, numCount.Value)

        Me.Hide()

    End Sub
End Class